<!DOCTYPE html>
<html>
	<head>
           <LINK href="style.css" rel="stylesheet" type="text/css">
           <title>Mariachi Casa</title>
           <style>
              body {
                 background-image:url('chips-and-salsa.jpg');
                 background-repeat:no-repeat;
              }
           </style>
           <meta name="google-translate-customization" content="457c7458d78f1fda-c04c9be73e1a028e-g6dbca1555c3b1007-18"></meta>
	</head>

<!-- ------------------------------------------------------------------- -->
<script>
function help(){
	alert("A waiter is on the way to help you.");
	//send a note to the waiters that this tablet needs help
}

function refill(){
	//refill screen popup
	window.open('../refill_page/refillScreen.html','refillWindow','titlebar=no, menubar=no, toolbar=no');
}
</script>
<!-- ------------------------------------------------------------------- -->



<body>
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'es', layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>   

<?php

	//constraints:
	require_once '../database/sql.php'; //info to connect to mysql
	require_once '../modules/customer.php'; //contains customer class
	session_start(); //begin session to access global data

/*******************************Second Perspective******************************/
	if($_POST) {

		// process order
                if($_POST['order']){
                   foreach($_SESSION['left_side_object'] as $value) 
                      $_SESSION['customer']->plate($value);

                    // write contents to file
                    file_put_contents('../tables/table1',$_SESSION['customer']->output());
                }
		//terminate session
		if($_POST['logout']) {
                   unset($_SESSION['customer']);
                   unset($_SESSION['right_side']);
                   unset($_SESSION['left_side']);
                   unset($_SESSION['left_side_item']);
                   unset($_SESSION['left_side_object']);
                   unset($_SESSION['bottom_side']);
                   unset($_SESSION['bottom_side_item']);
                   unset($_SESSION['customer_plates']);
                   unset($_SESSION['played']);
		   unset($_SESSION['customer_data']);
                }

		//check the session for the object
		if($_SESSION['customer']) {
	//		$customer = $_SESSION['customer']; //set the object
			$_SESSION['customer']->meal($_POST); //make part of the customer
                        file_put_contents('../tables/table1',$_SESSION['customer']->output());
			$_SESSION['customer_data'] = array(
				'cost' => $_SESSION['customer']->cost,
				'calories' => $_SESSION['customer']->calories, 
				'drink' => $_SESSION['customer']->drink, 
				'plate' => $_SESSION['customer']->plate
			);

		} //end check

	} //conclude second perspective


/*******************************First Perspective********************************/

	//store global object
	if(!$_SESSION['customer']) {
		$customer = new CUSTOMER(1.1); //create customer at table number
		$_SESSION['customer'] = $customer; //store in session
	} // end global storage

	//commence table
	//echo '<table border="1">';
	//echo "<tr>\n";

        
        echo "<br/><br/><br/><br/>";
        

        // Logout Button
        echo "<form method=\"post\">\n";
        echo "<input type=\"submit\" name=\"logout\" value=\"Logout\" class=\"backButton\" />\n"; // End the session
        echo "</form>\n";
        echo "<br/>";

        // Logo
        echo "<img src=\"MariachiCasaLogo.png\" alt=\"Mariachi Casa\">";

        // process Drinks menu
	echo "<form method=\"post\" action=\"../drinks_page/drinks.php\">\n";
        echo "<div id=\"drinkButton\" style=\"float:left; width:45%\">";
	//echo "<input type=\"submit\" name=\"drinks\" value=\"Drinks\" class=\"menuButton\"/>\n";
        echo "<button class=\"menuButton\" onclick\"\">Drinks</button>\n";
        echo "</div>\n";
	echo "</form>\n";

	//process Food menu
	echo "<form method=\"post\" action=\"../menu_page/menu.php\">\n";
	//echo "<div id=\"foodButton\"><input type=\"submit\" name=\"menu\" value=\"Menu\" class=\"menuButton\"/></div><br/>\n";
        echo "<button class=\"menuButton\" onclick\"\">Menu</button>\n";
	echo "</form>\n";
        echo "<br/>";

	//echo "</tr>\n<tr>\n"; //break table column

	//process Ticket screen
	echo "<form method=\"post\" action=\"../payment_page/payment.php\">\n";
	echo "<div id=\"ticketButton\" style=\"float:left; width:45%\">";
        echo "<button class=\"menuButton\" onclick\"\">Ticket</button>\n";
//<input type=\"submit\" name=\"ticket\" value=\"Ticket\" class=\"menuButton\"/>
        echo "</div>\n";
	echo "</form>\n";

	//process Feedback screen
	echo "<form method=\"post\" action=\"../feedback_page/feedback.html\">\n";
	//echo "<div id=\"commentButton\"><input type=\"submit\" name=\"feedback\" value=\"Feedback\" class=\"menuButton\"/></div>\n";
        echo "<button class=\"menuButton\" onclick\"\">Feedback</button>\n";
	echo "</form>\n";
        echo "<br/>";

         // process Game screen
	 if(!$_SESSION['played']) {
         echo "<form method=\"post\" action=\"../game_page/gameScreen.php\">\n";
         echo "<div id=\"gameButton\">\n";
         //echo "<input type=\"submit\" name=\"gameScreen\" value=\"Game Screen\" class=\"menuButton\"/>\n";
        echo "<button class=\"menuButton\" onclick\"\">Game Screen</button>\n";
         echo "</div>\n";
         echo "</form>";
	 }

	//echo "</tr>\n"; //conclude rows
	//echo "</table>\n"; //conclude table

/*
	echo "<form method=\"post\">\n";
	echo "<input type=\"submit\" name=\"logout\" value=\"LogOut\" />\n"; //end the session
	echo "</form>\n";*/

        echo "<br/><br/><br/>";

        echo "<div id=\"pageBottom\">\n";
        echo "<button class=\"footerButton\" onclick=\"\help()">Help</button>\n";
        echo "<button class=\"footerButton\" onclick\"\refill()">Refill</button>";
?>
</body>

</html>
